Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes yield proc scheduling. Turns sleeps into an opcode #1539

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Cyberboss
Copy link
Contributor

@Cyberboss Cyberboss commented Nov 26, 2023

The behavior is now the same for either spawn or sleep:

  • delay < 0: Proc will continue immediately if nothing is scheduled in the same tick. Otherwise, same as delay == 0.
  • delay == 0: Proc scheduled on end of same tick.
  • delay > 0: Proc scheduled after n ticks.

This also fixes the ProcScheduler being able to still have queued procs when running multiple tests in serial.

Then, to fix perf issues I had to redo sleeping into an opcode:

  • Remove sleep from DMStandard.
  • Two new opcodes Sleep and BackgroundSleep (which is just sleep -1, much faster than popping a float off for background sleeps).
  • Create new lightweight async proc state for sleeping.
  • Compiler/runtime adjustments to handle new opcodes.
  • Added IOpenDreamGameTiming as a wrapper around IGameTiming that we can control in unit tests.

Closes #1262

Comment on lines +55 to +58
rand_seed(22475)
for(var/i in 1 to 10000)
world.log << "Rand-[i]:"
TestSequence(MODE_RAND)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to up the test timeout because this overran 500ms

@Cyberboss
Copy link
Contributor Author

Apparently this is still unperformant for the issue in question

@Cyberboss Cyberboss marked this pull request as draft November 29, 2023 20:14
- Remove `sleep` from DMStandard.
- Two new opcodes Sleep and BackgroundSleep (which is just `sleep -1`, much faster than popping a `float` off for background sleeps).
- Create new lightweight async proc state for sleeping.
- Compiler/runtime adjustments to handle new opcodes.
@Cyberboss Cyberboss marked this pull request as ready for review January 1, 2024 17:29
@Cyberboss Cyberboss changed the title Fixes yield proc scheduling Fixes yield proc scheduling. Turns sleeps into an opcode Jan 1, 2024
public void SleepDelayPushed() => WriteOpcode(DreamProcOpcode.Sleep);

public void Sleep(float delay) {
if(delay == -1.0f) // yielding
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be <= 0

@Cyberboss
Copy link
Contributor Author

Somethings still fucky, which is why the TGS tests are failing

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@boring-cyborg boring-cyborg bot added Client Involves the OpenDream client Compiler Involves the OpenDream compiler Runtime Involves the OpenDream server/runtime labels Feb 10, 2024
@ike709 ike709 mentioned this pull request Feb 11, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link

github-actions bot commented Apr 9, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@Cyberboss Cyberboss marked this pull request as draft September 23, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client Involves the OpenDream client Compiler Involves the OpenDream compiler Merge Conflict Runtime Involves the OpenDream server/runtime size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set background = TRUE procs are extremely slow
1 participant